import redis

r = redis.Redis(host='127.0.0.1', port=6379, db=3)

r.set('name', 'zhangsan')

print(r.get('name'))
# b'zhangsan'  默认是bytes格式,使用decode()
print(r.get('name').decode())


r.setex('user',10,'xin')
print(r.get('user'))